package cn.yh.register.common.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 定义发送信息服务
 */
@Service
public class RabbitService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    /**
     * 发送信息
     * @param exchange 定义交换机
     * @param routingKey 定义路由key
     * @param message 发送的信息
     * @return 是否发送成功
     */
    public boolean sendMessage(String exchange, String routingKey, Object message){
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }
}
